﻿$(document).ready(function () {
    var tblOrderList = $("#tbl_order_history_list");
    if (tblOrderList.find("tbody>tr").length == 0) {
        var html = "<tr><td colspan='5' style='text-align:center;'>您还没有订餐记录</td></tr>"
        tblOrderList.find("tbody").append(html);
    }
    else { tblOrderList.tablePagination(); }

});


function deleteItem(obj) {
    if (!confirm("确定取消？")) {
        return;
    }

    var currTr = $(obj).closest("tr");

    var data = new QueryData("UserProcess.ashx", "DeleteItem");
    data.SetQueryData(currTr, "item_id");

    var json = $.toJSON(data.Data);
    $.ajax({
        type: "POST",
        url: data.URL,
        dataType: "json",
        data: $.toJSON(data.Data),
        success: function (result) {
            if (!checkAjaxResult(result)) {
                return;
            }
            if (result["Result"] != "True") {
                $(currTr).remove();
                $("#tbl_order_history_list").tablePagination();
            }
            else {
                alert("操作失败！请刷新页面后重试，或与管理员联系！");
            }
        },
        error: function (result) {
        }
    });
}